package com.ichir.projects.uiflow.internal.impl;

import java.util.Collections;
import java.util.List;

import com.ichir.projects.uiflow.definition.FlowType;
import com.ichir.projects.uiflow.definition.IFlowPart;
import com.ichir.projects.uiflow.definition.ITransition;
import com.ichir.projects.uiflow.ui.api.IUiPart;

/**
 * Default Flow part implementation.
 * @author mahieddine
 * @since 1.0.0
 */
public class DefaultFlowPartImpl implements IFlowPart {

//	/**
//	 * Target flow part.
//	 */
//	private IFlowPart target;

//	/**
//	 * flow part transition (single) ID.
//	 */
//	private String eventId;

	/**
	 * Bound UI Part.
	 */
	private IUiPart uiPart;

	/**
	 * Flow part transition.
	 */
	private ITransition transition;

//	/**
//	 * Default implementation.
//	 * @param target target flow part
//	 * @param transitionId transition id
//	 */
//	public DefaultFlowPartImpl(IFlowPart target, String transitionId, IUiPart uiPart) {
//		this.target = target;
//		this.eventId = transitionId;
//		this.uiPart = uiPart;
//	}

	/**
	 * Default implementation.
	 * @param target target flow part
	 * @param transitionId transition id
	 */
	public DefaultFlowPartImpl(IUiPart uiPart, ITransition transition) {
		this.transition = transition;
		this.uiPart = uiPart;
	}

	@Override
	public Class<? extends IUiPart> getUiPartClassname() {
		return uiPart.getClass();
	}

	@Override
	public List<? extends ITransition> getTransitions() {
		//		ITransition transition = new ITransition() {
		//			@Override
		//			public IFlowPart getTo() {
		//				return target;
		//			}
		//			@Override
		//			public String getId() {
		//				return eventId;
		//			}
		//			@Override
		//			public boolean disposeView() {
		//				return false;
		//			}
		//		};
		return Collections.singletonList(transition);
	}

	@Override
	public String getId() {
		return this.getClass().getName();
	}

	@Override
	public FlowType getType() {
		return FlowType.ACTION;
	}

}
